package com.kotlin.tsw.usercenter.presenter

import com.kotlin.tsw.baselibrary.ext.execute
import com.kotlin.tsw.baselibrary.persenter.BasePresenter
import com.kotlin.tsw.baselibrary.rx.BaseSubScriber
import com.kotlin.tsw.usercenter.presenter.view.RegisterView
import com.kotlin.tsw.usercenter.service.UserService
import javax.inject.Inject

class RegisterPersenter @Inject constructor(): BasePresenter<RegisterView>(){
    @Inject
    lateinit var userService : UserService

    fun register(mobile: String, verifyCode: String, pwd: String) {
        /*
        * 业务逻辑
        * */
//        val userService = UserServiceImpl()
        if(!checkNetWork()){
            mView.onErorr("网络不可用")
            return
        }

        mView.showLoading()
        userService.register(mobile, verifyCode, pwd)
                .execute(object :BaseSubScriber<Boolean>(mView){
                    override fun onNext(t: Boolean) {
                        if (t) {
                            mView.onRegisterResult("注册成功")
                        }
                    }
                },lifecycleProvider)
//        mView.onRegisterResult(true)
    }
}